from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from apps.students.routes import router as students_router

tags_metadata = [
    {
        "name": "students",
        "description": "学生管理相关API",
        "externalDocs": {
            "description": "扩展文档",
            "url": "https://www.baidu.com",
        },
    },
    {
        "name": "测试",
        "description": "这是一个测试的api",
    },
]

app = FastAPI(
    # API 文档信息
    title="萃萃后台管理系统API",
    description="这是一个开源的项目, 大家开源免费使用, 有问题或者报名学习可以加微信18010070052",
    version="1.0.0",
    openapi_url="/api/v1/openapi.json",
    # 配置文档路径
    docs_url="/docs",
    redoc_url="/redoc",
    # 标签
    openapi_tags=tags_metadata
)

origins = [
    "*",
]

app.add_middleware(
    CORSMiddleware,
    allow_origins=origins,
    allow_credentials=True,
    allow_methods=["GET", "POST", "DELETE", "PUT"],
    allow_headers=["*"],
)
app.include_router(students_router)
